package cn.sccdlg.springboot.controller;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author RaoShuang
 * @emil 991207823@qq.com
 * @date 2020/10/30 21:08
 * springboot入门之 配置文件中属性注入
 *  4、@ConfigurationProperties 属性映射
 */
@Controller
@ConfigurationProperties(prefix = "person3")
public class Quick3Controller {

    private String name;
    private String addr;
    private Integer age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddr() {
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @RequestMapping("/quick3")
    @ResponseBody
    public String quick3(){
        //获得配置文件的信息
        return "name: " + name + "，addr=" + addr + "，age=" + age;
    }
}
